<template>
  <div class="info_main mt-5 ml-5">
    <div id="col-md-3">
      <span class="" style="font-size: 20px">选择院校所在省份：</span>
      <el-cascader
          size="large"
          :options="provs"
          v-model="selectProv"
          @change="handleChange"
          placeholder="选择院校所在省份...">
      </el-cascader>
    </div>
    <!--    搜素框  -->
    <div class="row mt-3">
<!--      <div class="col-md-1">-->
<!--        <el-button @click="toggleSelection()">取消选择</el-button>-->
<!--      </div>-->
      <div class="col-md-8">
        <el-input  type="text"
                   v-model="findName"
                   style="width: 500px;"
                   placeholder="请输入院校名称..."
                   clearable
                   @keyup.enter.native="searchByName">
        </el-input>
        <el-button type="primary" icon="el-icon-search" @click="searchByName()" class="ml-3" plain>搜索</el-button>
        <el-button type="info" icon="el-icon-delete" @click="clearFindInput()" class="ml-3">重置</el-button>
      </div>
      <!--      添加按钮-->
      <div class="col-md-4" align="right">
        <el-button @click="toggleSelection()">取消选择</el-button>
        <el-button type="danger" @click="handleMultipleDelete">批量删除</el-button>
        <el-button type="primary" @click="addOpen()" plain><i class="el-icon-plus pr-2" ></i>添加</el-button>
<!--        <el-button type="primary"  plain><i class="fa fa-cloud-upload pr-2"></i>导入</el-button>-->
      </div>
    </div>
    <div class="show_data mt-4">
      <el-table
          ref="multipleTable"
          v-horizontal-scroll="'always'"
          show-overflow-tooltip
          :data="collegeData"
          style="width: 100%"
          :cell-style="{color: '#666', fontFamily: 'Arial',fontSize:'17px'}"
          :header-cell-style="{background:'whitesmoke', fontFamily:'Helvetica',fontSize:'20px'}"
          height="700"
          @selection-change="handleSelectionChange"
          :filter-method="filterHandler"
          tooltip-effect="dark"
          :default-sort = "{prop: 'date', order: 'descending'}">
        <el-table-column
            type="selection"
            width="55">
        </el-table-column>
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="院校名称：">
                <span>{{ props.row.college_name }}</span>
              </el-form-item>
              <el-form-item label="研招网网址：">
                <a href="javascript:void(0);">{{ props.row.college_yz_url}}</a>
              </el-form-item>
              <el-form-item label="研究生院官网：">
                <a href="javascript:void(0);">{{ props.row.college_gf_url}}</a>
              </el-form-item>
              <el-form-item label="院校简介：">
                <span>{{ props.row.college_info }}</span>
              </el-form-item>
              <el-form-item label="图片：">
                <img :src="'/api/storage/college_img/'+props.row.college_img"
                     style="width:30%;height:30%;object-fit:contain;border-radius: 2px"  alt="...">
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column
            fixed
            prop="college_name"
            label="院校名称"
            width="150">
        </el-table-column>
        <el-table-column
            prop="cnt"
            label="收藏数"
            width="120">
          <template slot-scope="scope">
            <span >{{ scope.row.cnt }}</span>
          </template>
        </el-table-column>
        <el-table-column
            prop="college_city"
            label="所在省份"
            width="180">
        </el-table-column>
        <el-table-column
            prop="college_belong"
            label="院校隶属"
            width="180">
        </el-table-column>
        <el-table-column
            prop="college_label"
            label="院校标签"
            width="200">
          <template slot-scope="scope">
            <el-tag  disable-transitions type="primary" v-show="scope.row.college_label!=''">
              <span class="typeClass">{{ scope.row.college_label }}</span>
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
            fixed="right"
            label="操作"
            width="250">
          <template slot-scope="scope">
            <el-button
                size="mini"
                @click="edit(scope.$index, scope.row)">
              <span class="btnfontClass" >编辑</span>
            </el-button>
            <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)">
              <span class="btnfontClass" >删除</span>
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--    分页-->
      <div class="pagin mt-5 mb-5">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[1, 2,5,10]"
            :page-size="param.limit"
            layout="total, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>

      <!--编辑弹窗-->
      <el-dialog
          title="编辑院校信息"
          :visible.sync="editdialogVisible"
          width="70%">

        <!--        编辑表单-->
        <el-form ref="Editform" :model="Editform" label-width="100px" :rules="rules">

          <el-row>
            <el-col :span="12">
              <el-form-item label="院校名称" :label-width="formLabelWidth" prop="college_name">
                <el-input
                    show-word-limit
                    v-model="Editform.college_name"
                    maxlength="80"
                    :rows="2"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="标签" :label-width="formLabelWidth" prop="college_label">
                <el-input
                    show-word-limit
                    v-model="Editform.college_label"
                    maxlength="20"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

          </el-row>


          <el-row>
            <el-col :span="12">
              <el-form-item label="院校隶属" :label-width="formLabelWidth" prop="college_belong">
                <el-input
                    show-word-limit
                    v-model="Editform.college_belong"
                    maxlength="50"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="省份" :label-width="formLabelWidth" prop="college_city">
                <el-cascader
                    size="large"
                    :options="provs"
                    v-model="Editform.college_city"
                    placeholder="选择院校所在省份..."
                    clearable
                    filterable>
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>


          <el-row>
            <el-col :span="12">
              <el-form-item label="研招网网址" :label-width="formLabelWidth" prop="college_yz_url">
                <el-input
                    show-word-limit
                    v-model="Editform.college_yz_url"
                    maxlength="100"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="研究生院官网" :label-width="formLabelWidth" prop="college_gf_url">
                <el-input
                    show-word-limit
                    v-model="Editform.college_gf_url"
                    maxlength="100"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

          </el-row>


          <el-form-item label="院校简介" :label-width="formLabelWidth" prop="college_info">
            <el-input
                show-word-limit
                type="textarea"
                maxlength="3000"
                :rows="10"
                v-model="Editform.college_info"></el-input>
          </el-form-item>

          <el-form-item label="上传图片：" :label-width="formLabelWidth" prop="college_img">
            <el-upload ref="upload_Edit"
                       name="upload_Edit"
                       action="#"
                       drag
                       :file-list="fileList_Edit"
                       list-type="picture"
                       :limit="1"
                       :on-exceed="handleExceed_Edit"
                       :auto-upload="false"
                       :on-remove="handleRemove_Edit"
                       :on-change="imgChange_Edit">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
              <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
            </el-upload>
          </el-form-item>

        </el-form>

        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="editSave('Editform')">修 改</el-button>
          <el-button @click="openCancelEdit">取 消</el-button>
        </span>
      </el-dialog>

      <!--添加弹窗-->
      <el-dialog
          title="添加院校信息"
          :visible.sync="addialogVisible"
          width="70%"
          @close="handleClose">

        <!--        添加表单-->
        <el-form ref="Addform" :model="Addform" label-width="100px" :rules="rules" :before-close="closeDiv">

          <el-row>
            <el-col :span="12">
              <el-form-item label="院校名称" :label-width="formLabelWidth" prop="college_name">
                <el-input
                    show-word-limit
                    v-model="Addform.college_name"
                    maxlength="80"
                    :rows="2"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="标签" :label-width="formLabelWidth" prop="college_label">
                <el-input
                    show-word-limit
                    v-model="Addform.college_label"
                    maxlength="20"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="院校隶属" :label-width="formLabelWidth" prop="college_belong">
                <el-input
                    show-word-limit
                    v-model="Addform.college_belong"
                    maxlength="50"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="省份" :label-width="formLabelWidth" prop="college_city">
                <el-cascader
                    size="large"
                    :options="provs"
                    v-model="Addform.college_city"
                    placeholder="选择院校所在省份..."
                    clearable
                    filterable>
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>


          <el-row>
            <el-col :span="12">
              <el-form-item label="研招网网址" :label-width="formLabelWidth" prop="college_yz_url">
                <el-input
                    show-word-limit
                    v-model="Addform.college_yz_url"
                    maxlength="100"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="研究生院官网" :label-width="formLabelWidth" prop="college_gf_url">
                <el-input
                    show-word-limit
                    v-model="Addform.college_gf_url"
                    maxlength="100"
                    type="text">
                </el-input>
              </el-form-item>
            </el-col>

          </el-row>


          <el-form-item label="院校简介" :label-width="formLabelWidth" prop="college_info">
            <el-input
                show-word-limit
                type="textarea"
                maxlength="3000"
                :rows="10"
                v-model="Addform.college_info"></el-input>
          </el-form-item>

          <el-form-item label="图片：" :label-width="formLabelWidth" prop="college_img">
            <el-upload ref="upload"
                       name="upload"
                       action="#"
                       drag
                       :file-list="fileList"
                       list-type="picture"
                       :limit="1"
                       :on-exceed="handleExceed"
                       :auto-upload="false"
                       :on-remove="handleRemove"
                       :on-change="imgChange">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
              <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
            </el-upload>
          </el-form-item>

        </el-form>

        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitAdd('Addform')">发 布</el-button>
          <el-button @click="cancel">取 消</el-button>
          <el-button @click="clearInput('Addform')">重 置</el-button>
        </span>
      </el-dialog>

    </div>
  </div>
</template>

<script>
import {getAllCollegeInfo,deleteCollegeByID} from "@/api/College";
import {deletePeeInfo} from "@/api/Pee";


export default {
  name: "college_info",
  data() {
    return {
      //搜索相关功能
      findName:'',
      //省份联动
      provs:[
        {label:"北京",value:"北京"},
        {label:"天津",value:"天津"},
        {label:"河北",value:"河北"},
        {label:"山西",value:"山西"},
        {label:"内蒙古",value:"内蒙古"},
        {label:"辽宁",value:"辽宁"},
        {label:"吉林",value:"吉林"},
        {label:"黑龙江",value:"黑龙江"},
        {label:"上海",value:"上海"},
        {label:"江苏",value:"江苏"},
        {label:"浙江",value:"浙江"},
        {label:"安徽",value:"安徽"},
        {label:"福建",value:"福建"},
        {label:"江西",value:"江西"},
        {label:"山东",value:"山东"},
        {label:"河南",value:"河南"},
        {label:"湖北",value:"湖北"},
        {label:"湖南",value:"湖南"},
        {label:"广东",value:"广东"},
        {label:"广西",value:"广西"},
        {label:"海南",value:"海南"},
        {label:"重庆",value:"重庆"},
        {label:"四川",value:"四川"},
        {label:"贵州",value:"贵州"},
        {label:"云南",value:"云南"},
        {label:"西藏",value:"西藏"},
        {label:"陕西",value:"陕西"},
        {label:"甘肃",value:"甘肃"},
        {label:"青海",value:"青海"},
        {label:"宁夏",value:"宁夏"},
        {label:"新疆",value:"新疆"},
        {label:"台湾",value:"台湾省"},
        {label:"香港",value:"香港"},
        {label:"澳门",value:"澳门"}
      ] ,
      selectProv: '',
      //分页
      param: {
        find_name_key: '',
        find_provs_key: '',
        page: 1,
        limit: 12,
      },
      total:0,
      currentPage: 1,
      collegeData: [],
      multipleSelection: [],
      //  添加弹窗相关
      addialogVisible:false,
      Addform:{
        college_id:'',
        college_name:'',
        college_info:'',
        college_city:'',
        college_label:'',    //可为空
        college_yz_url:'',
        college_gf_url:'',
        college_belong:''


      },
      //添加弹窗的上传图片相关
      fileList:[],
      file:[],
      //  编辑功能相关
      editdialogVisible:false,
      Editform:{
        college_id:'',
        college_name:'',
        college_info:'',
        college_city:'',
        college_label:'',    //可为空
        college_yz_url:'',
        college_gf_url:'',
        college_belong:''
      },
      formLabelWidth: '100px',
      //编辑表单验证规则
      rules: {
        college_name: [
          { required: true, message: '请输入院校名称', trigger: 'blur'},
          { min:1, max: 80, message: '长度在 1 到 80 个字符', trigger: 'blur'}
        ],
        college_info: [
          { min:1, max: 3000, message: '长度在 1 到 3000 个字符', trigger: 'blur'}
        ],
        college_city: [
          { required: true, message: '请选择院校所在省份', trigger: 'change'}
        ],
        college_label: [
          { min:1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur'}
        ],
        college_belong: [
          { min:1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur'}
        ],
        college_yz_url: [
          { min:1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur'}
        ],
        college_gf_url: [
          { min:1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur'}
        ],



      },
    //  编辑弹窗的重新上传图片相关
      fileList_Edit:[],
      file_Edit:[],

    }
  },

  methods: {
    //获取全部院校信息
    init(){
      getAllCollegeInfo({
        token: window.sessionStorage.getItem('token'),
        page:this.param.page,
        limit: this.param.limit,
        find_name_key:this.param.find_name_key,
        find_provs_key:this.param.find_provs_key
      }).then(res=>{
        this.collegeData=res.data.data;
        this.total=res.data.total;

      })
    },
    //  添加弹窗 图片上传相关
    // 文件列表移除文件时的钩子
    handleRemove(file, fileList) {
      this.fileList = [];  //将列表清空
      this.fileList.length = 0;
      fileList=[];
      fileList.length=0;
      this.$refs.upload.clearFiles();
    },
    //  点击文件列表中已上传的文件时的钩子
    handlePreview(file) {
      console.log(file);
    },
    //限制上传数量
    handleExceed (file, fileList) {
      this.$msg.warning('只能上传一张图片！');
    },
    //限制用户上传的图片格式和大小。
    imgChange (file,fileList) {

      this.fileList = fileList;
      var img_type = file.name.substring(file.name.lastIndexOf('.') + 1)
      var imgSize = file.size;
      var img_maxsize = 1024 * 500;

      console.log(img_type=='jpg');

      if ((img_type != 'jpg') && (img_type != 'png') && (img_type != 'JPG') && (img_type != 'JPEG') && (img_type != 'jpeg')) {
        this.fileList = [];  //将列表清空
        this.$message.warning('上传图片只能是JPG或PNG或JPEG格式!');
        return false;
      }

      if (imgSize>img_maxsize) {
        this.fileList = [];  //将列表清空
        this.$message.warning('上传图片大小不能超过500KB!');
        return false;
      }

      return true;
      //this.$refs.uploadElement.clearValidate();

    },

    //编辑弹窗 图片上传相关
    // 文件列表移除文件时的钩子
    handleRemove_Edit(file, fileList) {
      this.fileList_Edit = [];  //将列表清空
      this.fileList_Edit.length = 0;
      fileList=[];
      fileList.length=0;
      this.$refs.upload_Edit.clearFiles();
    },
    //限制上传数量
    handleExceed_Edit (file, fileList) {
      this.$msg.warning('只能上传一张图片！');
    },
    //限制用户上传的图片格式和大小。
    imgChange_Edit (file,fileList) {

      this.fileList_Edit = fileList;
      var img_type = file.name.substring(file.name.lastIndexOf('.') + 1)
      var imgSize = file.size;
      var img_maxsize = 1024 * 500;

      console.log(img_type=='jpg');

      if ((img_type != 'jpg') && (img_type != 'png') && (img_type != 'JPG') && (img_type != 'JPEG') && (img_type != 'jpeg')) {
        this.fileList_Edit = [];  //将列表清空
        this.$message.warning('上传图片只能是JPG或PNG或JPEG格式!');
        return false;
      }

      if (imgSize>img_maxsize) {
        this.fileList_Edit = [];  //将列表清空
        this.$message.warning('上传图片大小不能超过500KB!');
        return false;
      }

      return true;

    },
    //根据院校名进行搜索
    searchByName(){
      var search=this.findName;
      if(search==""||search==null)
      {
        this.$msg.error('输入框不能为空！');
        this.init();
      }
      else {
        this.param.find_name_key=this.findName;
        this.param.find_provs_key='';
        this.init();
        this.findName="";
      }

    },
    //分页
    //搜索一页多少条
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.param.limit=val;
      this.init();
    },
    //搜索第几页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.param.page=val;
      this.init();
    },
    //编辑院校信息  打开编辑弹窗
    edit(index, row) {
      this.editdialogVisible=true;
      // console.log(row);
      this.Editform.college_name=row.college_name;
      this.Editform.college_info=row.college_info;
      this.Editform.college_label=row.college_label;
      this.Editform.college_city=row.college_city;
      this.Editform.college_yz_url=row.college_yz_url;
      this.Editform.college_gf_url=row.college_gf_url;
      this.Editform.college_id=row.college_id;
      this.Editform.college_belong=row.college_belong;

    },
    //提交数据 修改
    editSave(formName)
    {
      //验证
      this.$refs[formName].validate((valid) => {
        if (valid) {
          //再次确认
          this.$confirm('确认修改?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.updateSave();
          }).catch(() => {
            this.$msg.error("修改失败！");
          });
        } else {
          this.$msg.error("修改失败！");
          return false;
        }
      });
    },
    //连接后端  进行修改
    async updateSave(){

      let formData = new FormData();
      //没有上传图片
      if(this.fileList_Edit.length==0){
        formData.append('if_img',0);
      }
      //上传了图片
      else {
        formData.append('if_img',1);
        formData.append('college_img', this.fileList_Edit[0].raw);
      }

      formData.append('college_id',this.Editform.college_id);
      formData.append('college_name',this.Editform.college_name);
      formData.append('college_info',this.Editform.college_info);
      formData.append('college_yz_url',this.Editform.college_yz_url);
      formData.append('college_gf_url',this.Editform.college_gf_url);
      formData.append('college_city',this.Editform.college_city);
      formData.append('college_label',this.Editform.college_label);
      formData.append('college_belong',this.Editform.college_belong);

      this.$ajax({
        url: "/api/College/updateCollegeInfo",
        method: "post",
        dataType:'text',
        cache:  false , //上传文件无需缓存
        processData:  false , //用于对data参数进行序列化处理 这里必须false
        contentType:  false ,  //
        data: formData
      }).then((result)=>{

        if (result.data.code == 1) {
          this.$msg.success("修改成功！");

          this.clearFindInput();

        }
        else{
          this.$msg.error("修改失败！");
        }
      });

      this.$refs.upload_Edit.clearFiles();
      this.editdialogVisible=false;


    },
    //删除
    handleDelete(index, row) {
      //再次确认
      this.$confirm('确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteSave(row.college_id);
      }).catch(() => {
        this.$msg.error("取消删除！");
      });
    },
    //连接后端，进行删除
    deleteSave(college_id){
      deleteCollegeByID({
        college_id:college_id,
        token: window.sessionStorage.getItem('token')
      }).then(res=>{
        if(res.data.code==1){
          this.$msg.success("删除成功！");
        }else{
          this.$msg.error("删除失败！");
        }
        this.clearFindInput();
      })

    },
    //打开添加的弹窗
    addOpen(){
      this.addialogVisible=true;
    },
    submitAdd(formName){
      //验证
      this.$refs[formName].validate((valid) => {
        if (valid) {
          //再次确认
          this.$confirm('确认添加?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.addSave();
          }).catch(() => {
            this.$msg.error("添加失败！");
          });
        } else {
          this.$msg.error("取消添加！");
          return false;
        }
      });

    },
    //连接后端 添加院校信息
    async addSave(){

      let formData = new FormData();
      //没有上传图片
      if(this.fileList.length==0){
        formData.append('if_img',0);
      }
      //上传了图片
      else {
        formData.append('if_img',1);
        formData.append('college_img', this.fileList[0].raw);
      }

      formData.append('college_name',this.Addform.college_name);
      formData.append('college_info',this.Addform.college_info);
      formData.append('college_city',this.Addform.college_city);
      formData.append('college_label',this.Addform.college_label);
      formData.append('college_yz_url',this.Addform.college_yz_url);
      formData.append('college_gf_url',this.Addform.college_gf_url);
      formData.append('college_belong',this.Addform.college_belong);

      this.$ajax({
        url: "/api/College/addCollegeInfo",
        method: "post",
        dataType:'text',
        cache:  false , //上传文件无需缓存
        processData:  false , //用于对data参数进行序列化处理 这里必须false
        contentType:  false ,  //
        data: formData
      }).then((result)=>{

        if (result.data.code == 1) {
          this.$msg.success("添加成功！");
          // this.addialogVisible=false;
        }else if(result.data.code==2){
          this.$msg.error("添加失败！院校库中已存在该院校");
          //刷新表格数据
          this.init();
          //关闭弹窗
          this.addialogVisible=false;
        }
        else{
          this.$msg.error("添加失败！");
        }
      });

      this.$refs.upload.clearFiles();
      this.addialogVisible=false;
      this.clearFindInput();

    },
    //重置按钮
    clearInput(formName){
      this.$refs[formName].resetFields();
      this.$refs.upload.clearFiles();
      this.fileList = [];  //将列表清空
      this.fileList.length = 0;
    },
    //  关闭弹窗
    cancel() {
      this.addialogVisible = false
      // 点击取消按钮的时候清除输入框中的内容 清除验证
      //  this.$nextTick获取了节点之后进行操作
      this.$nextTick(() => {
        // form对应你写的<el-form ref="form"></el-form>
        this.$refs["Addform"].resetFields();
      });
      this.fileList = [];  //将列表清空
      this.fileList.length = 0;
      this.$refs.upload.clearFiles();

    },
    openCancelEdit(){
      this.editdialogVisible = false
    },
    // 右上角 × 取消按钮
    closeDiv() {

      this.$nextTick(() => {
        // form对应你写的<el-form ref="form"></el-form>
        this.$refs["Addform"].resetFields();
      });
      this.fileList = [];  //将列表清空
      this.fileList.length = 0;
      this.$refs.upload.clearFiles();

    },
    //清空搜索框
    clearFindInput(){
      this.selectProv=[];
      this.findName='';
      this.param.find_provs_key='';
      this.param.find_name_key='';
      this.init();
    },
    handleClose(){
      this.$nextTick(() => {
        // form对应你写的<el-form ref="form"></el-form>
        this.$refs["Addform"].resetFields();
      });
      this.fileList = [];  //将列表清空
      this.fileList.length = 0;
      this.$refs.upload.clearFiles();

    },
    //取消选择
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    //多选
    handleSelectionChange(val) {
      this.multipleSelection = val;

    },
    filterHandler(value, row, column) {
      const property = column['property'];
      return row[property] === value;
    },
    //  批量删除
    handleMultipleDelete(rows){
      if (this.multipleSelection == '') {
        this.$message.error('您未选中任何院校，请重新操作！！！');
        return;
      }

      let checkArr = this.multipleSelection;  // multipleSelection存储了勾选到的数据
      let college_ids = [];
      checkArr.forEach(function (item) {
        college_ids.push(item.college_id);

      });

      //再次确认
      this.$confirm('确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {


        deleteCollegeByID({
          college_id:college_ids,
          token: window.sessionStorage.getItem('token')
        }).then(res=>{
          if(res.data.code==1){
            this.$msg.success("批量删除成功！");
          }else{
            this.$msg.error("删除失败！");
          }
          this.init();
        });

      }).catch(() => {
        this.$msg.error("取消删除！");
      });


    },
    //根据院校地区搜索
    handleChange(){
      this.param.find_provs_key=this.selectProv[0];
      this.param.find_name_key='';
      this.init();
    },




  },
  created() {

    let _this=this;

    _this.init();

    _this.$refs.table.doLayout();


  },
}
</script>

<style scoped>
.btnfontClass{
  font-size: 15px;
}
.el-pagination {
  text-align: center;
}
.typeClass{
  font-size: 14px;
}
/*表格展开功能样式*/
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 70%;
}

</style>
